//Cracking the coding interview (5th), 1_2
//Implement a function void reverse(char* str) in C or C++ which reverses a null-terminated string 
//8:14PM-8:19PM(bug free)

#include<iostream>
using namespace std;

void reverse(char *str) 
{
	if(*str) {
		char* end=str;
		char* start=str;
		char temp;

		while(*start) 
			start++;
		start--;

		while(start > end) {
			temp = *start;
			*start-- = *end;
			*end++ = temp;
		}
	}
}

int main(int argc, char *argv[]) 
{
	char a[] = "This is Pu Wei!";
	reverse(a);
	cout << a << endl;
	return 0;
}
